<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="product" tagdir="/WEB-INF/tags/product"%>
<%@ taglib prefix="catalog" tagdir="/WEB-INF/tags/catalog"%>
<%@ taglib prefix="eai" tagdir="/WEB-INF/tags/eai"%>

<content tag="buttons">
	<authorize:authorizeResource resourceString="/product/prod/*.html?doAction=*ave*">
		<probiz:iconBtn btnType="save" onclick="saveProduct(0);" disabled="yes" />
		<probiz:iconBtn btnType="save" btnTextKey="product.button.saveAndReturnToList" onclick="saveProduct(1);" disabled="yes" id="saveAndReturn"/>
		<probiz:iconBtn btnType="save" btnTextKey="product.button.saveAndAddSimilar" onclick="saveProduct(2);" disabled="yes" id="saveAndAddSimilar"/>
	</authorize:authorizeResource>
	<authorize:authorizeResource resourceString="/product/prod.html?doAction=*Delete*">
	  	<probiz:iconBtn btnType="delete" onclick="deleteProduct();" disabled="yes"/>
	</authorize:authorizeResource>
  	<probiz:iconBtn btnType="back" onclick="returnToList();" />
</content>

<div id="errorMsgExtraBar" class="warning_msg"  style="display: none"></div>
<div id="successMsgExtraBar" class="success_msg" style="display: none"></div>
<c:if test="${empty product.productId}">
	<div class="warning_msg" id="productStepInfo">
		<b><fmt:message key="productForm.step2"/></b><br/>
	</div>			
</c:if>

<div class="top clearfix">
	<ul class="tab" id="detail">
		<li class="curr">
			<a href="#tab-summary"><span><fmt:message key="productDetail.tab.summary" /> </span> </a>
		</li>
		<li>
			<a href="#tab-attribute"><span><fmt:message key="productDetail.tab.attribute" /> </span> </a>
		</li>
		<li>
			<a href="#tab-recommended"><span><fmt:message key="productDetail.tab.recommended" /> </span> </a>
		</li>
		<li>
			<a href="#tab-other"><span><fmt:message key="productDetail.tab.other" /> </span> </a>
		</li>
	</ul>
</div>
 	<div class="modify">
	<form id="productForm" name="productForm"	action="${ctxPath}/product/prod.html">
		<div id="tab-summary">
			<div class="p_edit_basic">
				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="com_modi_table">
					<tr>
						<th colspan="2" class="title"><h4><fmt:message key="productDetail.group.basic"/><h4></th>
					</tr>
					<tr>
						<td valign="top"  width="550">				
       						<%@include file="include/productFormSummary.jspf"%>
       					</td>
       					<td valign="top" id="areaOfImages">
       						<%--@include file="include/productFormImages.jsp"--%>
       					</td>
       				</tr>
       			</table>
       		</div>	
       				
	        <%@include file="include/productFormPackage.jspf"%>
	        <div id="areaOfSkus">
	        	<%--@include file="include/productFormSkus.jsp"--%>
	        </div>
        	<%@include file="include/productFormDesc.jspf"%>
	    </div>    
	    <div id="tab-attribute">
        	<%@include file="include/productFormAttributes.jsp"%>
        </div>
	    <div id="tab-recommended">
        	<%@include file="include/productFormRecommended.jsp"%>
        </div>
	    <div id="tab-other">
        	<%@include file="include/productFormSeo.jspf"%>
        	<%@include file="include/productFormAccessories.jspf"%>
	    </div> 
       
	</form>
</div>

<c:if test="${empty param.direct or !param.direct}">
	<c:set var="plugin_upload" value="true" scope="request"/>
	<c:set var="plugin_newUpload" value="true" scope="request"/>
	<c:set var="plugin_htmlEditor" value="true" scope="request"/>
	<c:set var="ui_accordion" value="true" scope="request"/>	
	<c:set var="ui_sortable_js" value="true" scope="request"/>
	<c:set var="ui_datepicker_js" value="true" scope="request"/>
	<c:set var="ui_datepicker_zh_CN_js" value="true" scope="request"/>
	<script type="text/javascript"	src="${ctxPath}/scripts/probiz/product/productForm.js?rs=${appConfig.rs}"></script>
</c:if>

<div style="display:none">
	<probiz:ui_tabs tabsId="detail" />
	<probiz:plugin_newUpload fileInputId="accessoryUpload" fileQueueId="accessoryfileQueue" uploadCategory="productAccessory"  width="84" multi="true"  buttonImg="${ctxPath}/images/btn/add_attached_btn1.png" onComplete="uploadProductAccessoryhandler"/>
	
	<catalog:productCategorySelector selectorId="productCategorySelector" callbackFunc="selectCategoryCallback"/>
	<product:productSelector selectorId="productSelector" callbackFunc="selectRecommendedProductCallback" multiple="true"/>
	<product:productSkuSelector selectorId="productSkuSelector" callbackFunc="selectPackageProductCallback" multiple="true"/>
	<eai:disabled ids="productName,productCode,mainCategoryId,taxRate,salesMeasureUnitName,weightMeasureUnitName,productSkuCode,price,length,width,height"/>
</div>



<v:javascript formName="product" staticJavascript="false" />
<script type="text/javascript">

<%--start:初始化验证与变量--%>		
	initValidate();
	initVariables();
	weightUnit = "${weightUnit}";
	<c:choose>
		<c:when test="${not empty product.status}">
			productStatus = ${product.status};
		</c:when>
		<c:otherwise>
			productStatus = null;
		</c:otherwise>
	</c:choose>
	<%--end:初始化验证与变量--%>	
	
	<%--用ajax方法load 主要为了解决页面加载开始时候处理太多js带来的ie加载速度太慢问题。--%>
	$j('#areaOfImages').loading().load('${ctxPath}/product/prod/blank.html?doAction=loadAreaOfImages&productId=${product.productId}',null,loadImagesCallback);
	$j('#areaOfSkus').loading().load('${ctxPath}/product/prod/blank.html?doAction=loadAreaOfSkus&productId=${product.productId}&productTypeId=${product.productType.productTypeId}',null,loadSkusCallback);
	$j('#tab-recommended').load('${ctxPath}/product/prod/blank.html?doAction=loadAreaOfRecommended&productId=${product.productId}',null,loadRecommendsCallback);	
	loadAttributesCallback();
	<%-- 
		不用ajax load原因：图片类的商品属性无法在使用tab和ajax load的情况下显示上传按钮，上层的width和height均为0.
		$j('#tab-attribute').load('${ctxPath}/product/prod/blank.html?doAction=loadAreaOfAttributes&productId=${product.productId}&productTypeId=${product.productType.productTypeId}',null,loadAttributesCallback);
	--%>
    
   			
	<%--start:初始化商品包--%>
	<c:forEach items="${product.defaultProductSku.productPackageItems}" var="ppi">
		addPackageSku({"productSkuId":"${ppi.itemSku.productSkuId}","productSkuCode":"${ppi.itemSku.productSkuCode}","productName":"${ppi.itemSku.product.productName}","imageUrl":"${ppi.itemSku.imageUrl}","productImageUrl":"${ppi.itemSku.product.imageUrl}","quantity":"${ppi.quantity}"},false);
	</c:forEach>
	showPackageSkuMoveIcons();
	<%--end:初始化商品包--%>
	
	//start:quickTip 生成 原因：在tag中$j无法扑捉到对象;另外直接用id指定是为了提高在ie下的查找速度
	$j('#productName,#salesMeasureUnitName,#keywords,#shortDescription,#addAccessoriesBtn,#description').each(function(){
      	$j(this).after('<img id="'+this.id+'_tip" width="14" height="14" src="'+__ctxPath+'/images/validate/info.gif"/>');
		$j('#'+this.id+'_tip').PQuickTip({
	         source:'text',
	         title:'Help',
	         type:'help',
	         text:$j(this).attr("quickTip")
      	});
	
	});
	//end:quickTip 生成
</script>
